package com.rlyy.rsj.utils;


import org.apache.log4j.Logger;

public class UniqueID {
    protected static Logger log = Logger.getLogger(UniqueID.class);
	private static long ipSum = IdWorkerUtil.getIpSum();//TODO 只能临时解决一下，因为不同机器ip的和也是可能重复的
  //服务名
//    private static final String scfName = "wbest"; 
//    
//    private static final String ZOOKEEPERHOSTPORT  = 
//    		Global.getSingleton().getServiceConfig().getString("vip.framework.zookeeper.hostport");
//   
//    static {
//	    IdworkCode idworkCode = new IdworkCode(ZOOKEEPERHOSTPORT, scfName);
//	    long idworderCode = 0;
//        try {
//            log.info("=======初始化机器码==========开始");
//            idworderCode = idworkCode.getWorkerId();
//            log.info("=======初始化机器码==========完成，idworderCode：" + idworderCode);
//        } catch (Exception e) {
//            log.error("=======初始化机器码==========失败",e);
//        }
//	   
//		idWorder = new IdWorker(idworderCode);
//	}

	public static long generateId() {
	    return IdWorkerUtil.getInstance(ipSum).nextId();
	}
}
